<?php
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
	/* special ajax here */
	require_once ("connect.php"); 

	if(isset($_GET['action'])){
		$action = $_GET['action'];
		switch ($action) {
			case 'read':
				$sql = "select * from orders";
				$db->query("SET NAMES 'utf8'");
				$statement = $db->query($sql);
				$statement->execute();
				$statement->setFetchMode(PDO::FETCH_ASSOC);
				$array = array();
				while($row = $statement->fetch()){
					array_push($array, $row);
				}
				echo json_encode(array("orders"=>$array));
				break;
			case 'update' : 

				break;
			case 'create' : 
				$form_data = json_decode(file_get_contents('php://input'));
				$account_id = $form_data->account_id;
				echo json_encode(array(
		            "success" => true,
		        ));
				break;
			default:
				# code...
			break;
		}

	}

}

?>